@import '../../define.scss';

$button-border-radius: 5px;

.grid-panel-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow-y: auto;
  padding-bottom: $panel-h-padding;
  background-color: hsl(0, 0%, 97%);
}

.svg-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 1em;
  height: 1em;
  color: currentColor;

  pointer-events: fill;

  :global(svg) {
    fill: currentColor;
    width: 100%;
    height: 100%;
  }
}

.row-header {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  width: 100%;

  background-color: white;
  opacity: 0.93;

  border-bottom: 1px solid $gray-200;
  padding: 8px $panel-h-padding 6px $panel-h-padding;
  gap: 4px;

  position: sticky;
  top: 0px;
  z-index: 2;

  .label {
    font-size: 1rem;
    font-weight: 400;
    color: $gray-600;
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  #hidden-select {
    display: none;

    &::after {
      display: none;
    }
  }

  .select {
    position: relative;
    border-radius: 4px;
    border: 1px solid $gray-light-border;
    margin: 0 0 0 4px;
    line-height: 1.2;

    select {
      padding: 0 16px 0 6px;
      margin: 0px;
      border: none;
      position: relative;
      background-color: transparent;
      color: $gray-600;
      background-color: white;
      font-weight: 400;

      -moz-appearance: none;
      -webkit-appearance: none;
    }

    &::after {
      right: 6px;

      $select-border-color: $gray-600;
      border-right: 2px solid $select-border-color;
      border-top: 2px solid $select-border-color;

      content: '';
      display: block;
      height: 6px;
      width: 6px;
      pointer-events: none;
      position: absolute;
      top: 50%;
      transform: translateY(-50%) rotate(135deg);
      transform-origin: center;
    }
  }

  .svg-icon {
    fill: $gray-400;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 2px;

    :global(svg) {
      width: 1rem;
      height: 1rem;
    }
  }
}

.card-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;

  width: 100%;
  padding: $panel-h-padding $panel-h-padding;
  background-color: hsl(0, 0%, 97%);

  .card {
    width: 165px;
    box-shadow: 0px 0px 6px hsla(0, 0%, 0%, 0.07);
    border: 1px solid hsla(0, 0%, 0%, 0.1);
    border-radius: 6px;
    overflow: hidden;

    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;

    transition: transform 100ms ease-in-out, box-shadow 100ms ease-in-out;

    &:hover {
      transform: scale(1.02);
      transform-origin: center;
      box-shadow: 0px 0px 8px hsla(0, 0%, 0%, 0.13);
    }

    &:active {
      transform: scale(1.02) translateY(1px);
    }

    .thumbnail-container {
      width: 100%;
      aspect-ratio: 1 / 1;
      border-bottom: 1px solid $gray-300;
    }

    .thumbnail {
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: top left;
      transition: object-position 700ms linear;

      &:hover {
        object-position: bottom right;
        transition: object-position 1400ms linear;
      }
    }

    .name {
      width: 100%;
      padding: 0 5px;
      font-size: $font-d1;
      font-weight: 600;
      background-color: white;
      text-align: center;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

dialog[open] {
  border-radius: 8px;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 0;
  pointer-events: all;

  max-height: 600px;
  max-width: 600px;
  padding-bottom: 16px;

  &::backdrop {
    background-color: hsla(0, 0%, 0%, 0.75);
    animation: fade-in 300ms;
  }

  .header {
    padding: 16px 20px 0px 20px;
    margin: 0;
    line-height: 1;
    font-size: $font-u3;
    font-weight: 600;
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    min-width: 500px;

    .left {
      display: flex;
      gap: 7px;
      align-items: center;

      .svg-icon {
        height: 16px;
        width: 16px;
        color: $gray-900;
        transition: color 100ms ease-in-out;
        cursor: pointer;

        &:hover {
          color: $gray-800;
        }

        &:active {
          color: $gray-700;
        }
      }
    }
  }

  .close-button {
    color: $gray-500;
    transition: color 150ms ease-in-out;

    &:hover {
      color: $gray-600;
    }

    &:active {
      color: $gray-700;
    }
  }

  button.button {
    background-color: $gray-200;
    padding: 3px 8px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-grow: 0;
    transition: background-color 150ms ease-in-out;

    &:hover {
      background-color: $gray-300;
    }

    &:active {
      background-color: $gray-400;
    }

    &.add-button {
      background-color: $blue-500;
      color: white;
      border-color: $blue-500;

      &:hover {
        background-color: $blue-400;
      }

      &:active {
        background-color: $blue-600;
      }
    }
  }

  .button {
    background-color: $gray-200;
    color: $gray-800;
    padding: 3px 8px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-grow: 0;
    transition: background-color 150ms ease-in-out;
    border: 1px solid $gray-400;

    &:hover {
      background-color: $gray-300;
    }

    &:active {
      background-color: $gray-400;
    }
  }

  .content {
    display: flex;
    // align-items: stretch;

    padding: 0px 20px 0 20px;
    gap: 10px;

    max-height: 200px;
    max-width: 100%;

    .description {
      flex: 1;
      max-width: 100%;
      max-height: 100%;
      overflow-y: auto;

      font-size: $font-d1;
    }

    .thumbnail-container {
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: flex-start;

      .thumbnail {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;

        border: 1px solid $gray-border;
        border-radius: 5px;
      }
    }
  }

  .info-bar {
    display: flex;
    flex-direction: row;
    width: 100%;
    padding: 0px 20px 0 20px;
    font-size: $font-d2;
    flex-wrap: wrap;
    gap: 6px;

    .clip {
      background-color: $teal-600;
      color: white;
      padding: 1px 3px;
      border-radius: 5px;
    }
  }

  .bibtex-bar {
    width: 100%;
    display: flex;
    padding: 0px 20px 0 20px;
    font-size: $font-d2;
    flex-wrap: wrap;
  }

  .bibtex-short {
    color: $gray-800;

    .copy-text {
      padding-left: 4px;
      color: $teal-900;
      cursor: pointer;
      user-select: none;
      -webkit-user-select: none;

      &:hover {
        text-decoration: underline;
      }

      &:active {
        color: $teal-700;
      }
    }

    .svg-icon.copied-icon {
      display: inline-block;
      vertical-align: text-top;
      color: $teal-600;
      opacity: 0;
      transition: opacity 500ms;

      &:global(.shown) {
        opacity: 1;
      }
    }
  }
}
